<template>
  <div class="payment-success">
    <div class="success-content">
      <div class="success-icon">
        <i class="el-icon-success"></i>
      </div>
      <h2>支付成功</h2>
      <p class="order-number">订单号：{{ orderInfo.orderNumber }}</p>
      
      <div class="order-details">
        <div class="detail-item">
          <span class="label">服务项目：</span>
          <span class="value">{{ orderInfo.serviceTitle }}</span>
        </div>
        <div class="detail-item">
          <span class="label">预约时间：</span>
          <span class="value">{{ orderInfo.appointmentTime }}</span>
        </div>
        <div class="detail-item">
          <span class="label">服务地点：</span>
          <span class="value">{{ orderInfo.location }}</span>
        </div>
        <div class="detail-item">
          <span class="label">支付金额：</span>
          <span class="value price">¥{{ orderInfo.amount }}</span>
        </div>
      </div>

      <div class="action-buttons">
        <el-button type="primary" @click="viewOrder">查看订单</el-button>
        <el-button @click="goHome">返回首页</el-button>
      </div>

      <div class="tips">
        <h4>温馨提示：</h4>
        <ul>
          <li>您可以在"我的订单"中查看订单详情</li>
          <li>如需修改预约时间，请提前24小时联系客服</li>
          <li>如有任何问题，请联系客服：400-123-4567</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'PaymentSuccess',
  data() {
    return {
      orderInfo: {
        orderNumber: '',
        serviceTitle: '',
        appointmentTime: '',
        location: '',
        amount: 0
      }
    }
  },
  created() {
    // 从路由参数获取订单ID
    const orderId = this.$route.query.orderId
    if (orderId) {
      this.getOrderInfo(orderId)
    } else {
      this.$router.push('/orders')
    }
  },
  methods: {
    async getOrderInfo(orderId) {
      try {
        // 调用后端API获取订单信息
        // const response = await this.$http.get(`/api/orders/${orderId}`)
        // this.orderInfo = response.data
        
        // 模拟数据
        this.orderInfo = {
          orderNumber: `P${orderId}`,
          serviceTitle: '专业宠物美容套餐',
          appointmentTime: '2024-01-20 14:00-15:00',
          location: '到店服务',
          amount: 199
        }
      } catch (error) {
        this.$message.error('获取订单信息失败')
        this.$router.push('/orders')
      }
    },
    viewOrder() {
      this.$router.push(`/orders/${this.$route.query.orderId}`)
    },
    goHome() {
      this.$router.push('/')
    }
  }
}
</script>

<style scoped>
.payment-success {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

.success-content {
  background: white;
  padding: 40px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.success-icon {
  margin-bottom: 20px;
}

.success-icon i {
  font-size: 64px;
  color: #67c23a;
}

h2 {
  font-size: 28px;
  color: #333;
  margin-bottom: 10px;
}

.order-number {
  color: #666;
  font-size: 16px;
  margin-bottom: 30px;
}

.order-details {
  max-width: 400px;
  margin: 0 auto 30px;
  padding: 20px;
  background: #f9f9f9;
  border-radius: 8px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
}

.detail-item:last-child {
  margin-bottom: 0;
}

.detail-item .label {
  color: #666;
}

.detail-item .value {
  color: #333;
}

.detail-item .price {
  color: #f56c6c;
  font-weight: bold;
  font-size: 18px;
}

.action-buttons {
  margin-bottom: 30px;
}

.action-buttons .el-button {
  min-width: 120px;
  margin: 0 10px;
}

.tips {
  text-align: left;
  max-width: 400px;
  margin: 0 auto;
}

.tips h4 {
  color: #333;
  margin-bottom: 10px;
}

.tips ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tips li {
  color: #666;
  margin-bottom: 5px;
  padding-left: 20px;
  position: relative;
}

.tips li:before {
  content: "•";
  position: absolute;
  left: 0;
  color: #409EFF;
}
</style> 